package com.ibm.spatiotemp.test.requestServer.redis;


/** 
 * @author Yaoliang Chen
 * @version May 14, 2014 
 * Interface for PubSub
 */

public interface IPubSub {
	/**
	 * Initialize the instance
	 * @param hostname  the hostname of the pubsub server
	 * @param port   the port of the server.
	 */
	public abstract boolean init(String hostname, String port);
	
	/**
	 * subscribe messages from the given topic
	 * @param topic
	 */
	public abstract boolean subscribe(String... topic);
	
	/**
	 * subscribe multiple channels with pattern.
	 * @param pattern : the pattern of the channels 
	 * @return 
	 */
	public abstract boolean psubscribe(String pattern);

	/**
	 * publish a message from a given topic
	 * @param topic
	 * @param message
	 * @return 
	 */
	public abstract boolean publish(String topic, String message);
	
	/**
	 * Get the subscribed messages. 
	 * @return a String[2] array. A <code>null</code> indicates no message.
	 * 		String[0]: topic name; 
	 * 		String[1]: message
	 */
	public abstract String[] getMessage();
}